using System;
using System.Windows.Forms;
using CodePlex.DnD4eCampaignManager.DnD4e.Enums;
using CodePlex.DnD4eCampaignManager.Presentation;
using CodePlex.DnD4eCampaignManager.Presentation.ViewInterfaces;
using CodePlex.DnD4eCampaignManager.Repositories.Interfaces;

namespace CodePlex.DnD4eCampaignManager.ControlLibrary
{
    public partial class MonsterControl : UserControl, IMonsterView
    {
        public MonsterControl(string monsterName, IMonsterRepository monsterRepository)
        {
            InitializeComponent();
            RoleList.Items.Clear();
            RoleList.Items.Add(MonsterRole.Artillery);
            RoleList.Items.Add(MonsterRole.Brute);
            RoleList.Items.Add(MonsterRole.Controller);
            RoleList.Items.Add(MonsterRole.Lurker);
            RoleList.Items.Add(MonsterRole.Minion);
            RoleList.Items.Add(MonsterRole.Skirmisher);
            RoleList.Items.Add(MonsterRole.Soldier);
            SizeList.Items.Clear();
            SizeList.Items.Add(CreatureSize.Tiny);
            SizeList.Items.Add(CreatureSize.Small);
            SizeList.Items.Add(CreatureSize.Medium);
            SizeList.Items.Add(CreatureSize.Large);
            SizeList.Items.Add(CreatureSize.Huge);
            SizeList.Items.Add(CreatureSize.Gargantuan);
            Presenter = new MonsterPresenter(monsterName, this, monsterRepository);
            Presenter.DisplayMonster();
        }

        public int ActionPoints
        {
            get { return (int) ActionPointNumeric.Value; }
            set { ActionPointNumeric.Value = value; }
        }

        public int ArmorClass
        {
            get { return (int) ArmorClassDefenseNumeric.Value; }
            set { ArmorClassDefenseNumeric.Value = value; }
        }

        public string AttackPowers
        {
            get { return AttackPowersText.Text; }
            set { AttackPowersText.Text = value; }
        }

        public int Charisma
        {
            get { return (int) CharismaNumeric.Value; }
            set { CharismaNumeric.Value = value; }
        }

        public int Constitution
        {
            get { return (int) ConstitutionNumeric.Value; }
            set { ConstitutionNumeric.Value = value; }
        }

        public int Dexterity
        {
            get { return (int) DexterityNumeric.Value; }
            set { DexterityNumeric.Value = value; }
        }

        public bool Elite
        {
            get { return EliteCheck.Checked; }
            set { EliteCheck.Checked = value; }
        }

        public string Equipment
        {
            get { return EquipmentText.Text; }
            set { EquipmentText.Text = value; }
        }

        public int ExperiencePointValue
        {
            set { XPValueLabel.Text = string.Format("XP {0}", value); }
        }

        public int FortitudeDefense
        {
            get { return (int) FortitudeNumeric.Value; }
            set { FortitudeNumeric.Value = value; }
        }

        public int HitPoints
        {
            get { return (int) HitPointNumeric.Value; }
            set { HitPointNumeric.Value = value; }
        }

        public int InitiativeModifier
        {
            get { return (int) InitiativeModifierNumeric.Value; }
            set { InitiativeModifierNumeric.Value = value; }
        }

        public int Intelligence
        {
            get { return (int) IntellegenceNumeric.Value; }
            set { IntellegenceNumeric.Value = value; }
        }

        public string Keywords
        {
            get { return KeywordText.Text; }
            set { KeywordText.Text = value; }
        }

        public bool Leader
        {
            get { return LeaderCheck.Checked; }
            set { LeaderCheck.Checked = value; }
        }

        public int Level
        {
            get { return (int) LevelNumeric.Value; }
            set { LevelNumeric.Value = value; }
        }

        public string MonsterName
        {
            private get { return MonsterNameText.Text; }
            set { MonsterNameText.Text = value; }
        }

        public CreatureSize MonsterSize
        {
            get { return (CreatureSize) SizeList.SelectedItem; }
            set { SizeList.SelectedItem = value; }
        }

        public string Origin
        {
            get { return OriginText.Text; }
            set { OriginText.Text = value; }
        }

        public int Perception
        {
            get { return (int) PerceptionNumeric.Value; }
            set { PerceptionNumeric.Value = value; }
        }

        public int ReflexDefense
        {
            get { return (int) ReflexNumeric.Value; }
            set { ReflexNumeric.Value = value; }
        }

        public MonsterRole Role
        {
            get { return (MonsterRole) RoleList.SelectedItem; }
            set { RoleList.SelectedItem = value; }
        }

        public string SaveAsName { get; private set; }

        public int SavingThrows
        {
            get { return (int) SavingThrowNumeric.Value; }
            set { SavingThrowNumeric.Value = value; }
        }

        public string Senses
        {
            get { return SensesText.Text; }
            set { SensesText.Text = value; }
        }

        public string Skills
        {
            get { return SkillsText.Text; }
            set { SkillsText.Text = value; }
        }

        public bool Solo
        {
            get { return SoloCheck.Checked; }
            set { SoloCheck.Checked = value; }
        }

        public string SpecialQualities
        {
            get { return SpecialQualitiesText.Text; }
            set { SpecialQualitiesText.Text = value; }
        }

        public int Speed
        {
            get { return (int) SpeedNumeric.Value; }
            set { SpeedNumeric.Value = value; }
        }

        public string SpeedOther
        {
            get { return SpeedAdditionalText.Text; }
            set { SpeedAdditionalText.Text = value; }
        }

        public int Strength
        {
            get { return (int) StrengthNumeric.Value; }
            set { StrengthNumeric.Value = value; }
        }

        public string Tactics
        {
            get { return TacticsText.Text; }
            set { TacticsText.Text = value; }
        }

        public int WillpowerDefense
        {
            get { return (int) WillNumeric.Value; }
            set { WillNumeric.Value = value; }
        }

        public int Wisdom
        {
            get { return (int) WisdomNumeric.Value; }
            set { WisdomNumeric.Value = value; }
        }

        private MonsterPresenter Presenter { get; set; }

        private void SaveAsButton_Click(object sender, EventArgs e)
        {
            SaveAsName = ModalStringPicker.GetString("Save Monster As...", "What would you like to name the new monster?", MonsterNameText.Text, 600);
            Presenter.SaveMonster();
        }

        private void SaveButton_Click(object sender, EventArgs e)
        {
            SaveAsName = MonsterName;
            Presenter.SaveMonster();
        }
    }
}